import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import hide from '../../atom/hide';
import show from '../../atom/show';
import { anim, play } from '@feidao/animation';
import set from '@feidao/web/atom/browser/local/set';

export default async function a002(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 调用事件
	const type = args[0];
	const info = args[1];
	const fail_div = fd.data.node.querySelector('[data-feidao-id="fail_div"]') as HTMLElement;
	const success_div = fd.data.node.querySelector('[data-feidao-id="success_div"]') as HTMLElement;
	if (type === 'success') {
		const prompt_sucess = fd.data.node.querySelector('[data-feidao-id="prompt_sucess"]') as HTMLElement;
		prompt_sucess.innerHTML = info;
		show(success_div);
	} else if (type === 'fail') {
		const prompt_fail = fd.data.node.querySelector('[data-feidao-id="prompt_fail"]') as HTMLElement;
		prompt_fail.innerHTML = info;
		show(fail_div);
	}
	// 滑出
	play(anim(fd.data.node, {
	}, {
			top: {
				start: -50,
				end: -10
			}
		}));
	const d = window.setTimeout(() => {
		window.clearTimeout(d);
		play(anim(fd.data.node, {
		}, {
				top: {
					start: -10,
					end: -50
				}
			}));
		hide(success_div);
		hide(fail_div);
	}, 3000);
	set(fd, 'd', d);
}
